home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Player2.aspx.cs459 < prev    next >
Text File  |  2007-11-24  |  49KB  |  1,175 lines

  1. using System;
  2. using System.Globalization;
  3. using System.IO;
  4. using System.Web;
  5. using System.Web.UI;
  6. using GBPVR.Public;
  7. using GBPVRSchedule;
  8. using gbweb.classes;
  9.  
  10. namespace gbweb
  11. {
  12.     public partial class Player2 : Page
  13.     {
  14.         private Settings guideParams;
  15.         private string serverAddr;
  16.         private int vlcProfile;
  17.         private System.Diagnostics.Process proc;
  18.         private System.Diagnostics.ProcessStartInfo psi;
  19.  
  20.         protected void Page_Load(object sender, EventArgs e)
  21.         {
  22.  
  23.             getTheme();
  24.             vlcProfile = GetVlcProfile();
  25.             //Load settings
  26.             guideParams = Global.Settings;
  27.             if (!IsPostBack)
  28.             {
  29.                 playerOptions.Visible = true;
  30.                 MusicVideoControls.Visible = false;
  31.                 if (Request.Params["type"] == null)
  32.                 {
  33.                     if (vlcProfile == 1)
  34.                     {
  35.                         SETTINGS_HEADER.InnerHtml = "Player Options - Video Library";
  36.                     }
  37.                     else
  38.                     {
  39.                         SETTINGS_HEADER.InnerHtml = "Player Options - Music Library";
  40.                     }
  41.                 }
  42.                 else
  43.                 {
  44.                     if (Request.Params["type"] == "sn")
  45.                     {
  46.                         SETTINGS_HEADER.InnerHtml = "Player Options - Stream Now";
  47.                     }
  48.                     else
  49.                     {
  50.                         SETTINGS_HEADER.InnerHtml = "Player Options - Manage Recordings";
  51.                     }
  52.                 }
  53.                 transcodeOptions.Visible = false;
  54.  
  55.                 resetButton_Click(null, null);
  56.             }
  57.  
  58.             //This checks to see if the user clicked on a VLC server control button
  59.             if (Request.Form["__EVENTTARGET"] != null)
  60.             {
  61.                 if (Request.Form["__EVENTTARGET"].IndexOf("previousStream") != -1) previousStream(null, null);
  62.                 if (Request.Form["__EVENTTARGET"].IndexOf("skipBackwardStream") != -1) skipBackwardStream(null, null);
  63.                 if (Request.Form["__EVENTTARGET"].IndexOf("stopStream") != -1) stopStream(null, null);
  64.                 if (Request.Form["__EVENTTARGET"].IndexOf("playStream") != -1) playStream(null, null);
  65.                 if (Request.Form["__EVENTTARGET"].IndexOf("pauseStream") != -1) pauseStream(null, null);
  66.                 if (Request.Form["__EVENTTARGET"].IndexOf("skipForwardStream") != -1) skipForwardStream(null, null);
  67.                 if (Request.Form["__EVENTTARGET"].IndexOf("nextStream") != -1) nextStream(null, null);
  68.             }
  69.             else
  70.             {
  71.                 if ((Request.Params["mvid"] == null) && (Request.Params["mid"] == null) && (Request.Params["type"] == null))
  72.                 {
  73.                     streamButton.Visible = false;
  74.                 }
  75.             }
  76.         }
  77.  
  78.         private void AddKeepAlive()
  79.         {
  80.             //Routine to keep session alive
  81.             int int_MilliSecondsTimeOut = (Session.Timeout * 60000) - 30000;
  82.             string str_Script = @"
  83.                 <script type='text/javascript'>
  84.                 //Number of Reconnects
  85.                 var count=0;
  86.                 //Maximum reconnects setting
  87.                 var max = 5;
  88.                 window.status = 'Auto Reconnect Script is Activated'
  89.                 function Reconnect(){
  90.                 count++;
  91.                 if (count < max)
  92.                 {
  93.                 window.status = 'Link to Server Refreshed ' + count.toString()+' time(s)' ;
  94.  
  95.                 var img = new Image(1,1);
  96.  
  97.                 img.src = 'keepalive.aspx';
  98.  
  99.                 }
  100.                 }
  101.  
  102.                 window.setInterval('Reconnect()'," + int_MilliSecondsTimeOut.ToString() + @"); //Set to length required
  103.  
  104.                 </script>
  105.  
  106.                 ";
  107.  
  108.             ClientScript.RegisterStartupScript(typeof(String), "Reconnect", str_Script, false);
  109.         }
  110.  
  111.  
  112.         private void AddPlayerScript()
  113.         {
  114.             //Insert script to the client to play the VLC Plugin
  115.             int int_MilliSecondsTimeOut = (Session.Timeout * 60000) - 30000;
  116.             string options = "";
  117.             string str_Script = "";
  118.  
  119.             VLCCommon VLC = new VLCCommon(vlcProfile);
  120.  
  121.             if (VLC.strmPlayer == "vlc")
  122.             {
  123.                 if (Request.ServerVariables["HTTP_USER_AGENT"].IndexOf("MSIE") > 0)
  124.                 {
  125.                     str_Script = @"
  126.                     <script>
  127.                         window.status = 'Play Stream Activated'
  128.                         function playVideo()
  129.                         {
  130.                         var options = new Array('http-caching=";
  131.                     str_Script += VLC.strmBuffer;
  132.                     str_Script += @"');
  133.                     ";
  134.                     string location = "document.video1.addTarget('http://" + serverAddr + "', options , 4+8, -666);";
  135.                     str_Script += location;
  136.                     str_Script += @"
  137.                                window.status = 'Play Button Clicked';
  138.                                document.video1.play();
  139.                         }
  140.                     </script>
  141.  
  142.                     ";
  143.                 }
  144.                 else
  145.                 {
  146.                     str_Script = @"
  147.                     <script>
  148.                         function playVideo()
  149.                         {
  150.                                document.video1.play();
  151.                         }
  152.                     </script>
  153.  
  154.                     ";
  155.                 }
  156.             }
  157.  
  158.             ClientScript.RegisterStartupScript(typeof(String), "playVideo", str_Script, false);
  159.         }
  160.  
  161.         protected void streamButton_Click(object sender, EventArgs e)
  162.         {
  163.             MusicVideoControls.Visible = true;
  164.             
  165.             playerOptions.Visible = false;
  166.             transcodeOptions.Visible = false;
  167.             settingsButtons.Visible = false;
  168.             pluginArea.Visible = false;
  169.  
  170.             VLCCommon VLC = new VLCCommon(vlcProfile);
  171.             if (VLC.strmPlayer == "dnld")
  172.             {
  173.                 launchPlayer.Text = "Launch Download";
  174.             }
  175.             else
  176.             {
  177.                 if (VLC.strmExternal)
  178.                 {
  179.                     launchPlayer.Text = "Launch External Player"; 
  180.                 }
  181.                 else
  182.                 {
  183.                     launchPlayer.Text = "Launch Plugin";
  184.                 }
  185.             }
  186.  
  187.             if (Request.Params["type"] == null)
  188.             {
  189.                 if (vlcProfile == 1)
  190.                 {
  191.                     SETTINGS_HEADER.InnerHtml = "Streamer Controls - Video Library";
  192.                 }
  193.                 else
  194.                 {
  195.                     SETTINGS_HEADER.InnerHtml = "Streamer Controls - Music Library";
  196.                 }
  197.             }
  198.             else
  199.             {
  200.                 if (Request.Params["type"] == "sn")
  201.                 {
  202.                     SETTINGS_HEADER.InnerHtml = "Streamer Controls - Stream Now";
  203.                 }
  204.                 else
  205.                 {
  206.                     SETTINGS_HEADER.InnerHtml = "Streamer Controls - Manage Recordings";
  207.                 }
  208.             }
  209.  
  210.             if (((Request.Params["mvid"] != null) && (Request.Params["mvid"].Length != 0)) ||
  211.                 ((Request.Params["mid"] != null) && (Request.Params["mid"].Length != 0)) ||
  212.                 ((Request.Params["type"] != null) && (Request.Params["type"].Length != 0)))
  213.                 {
  214.                     AddKeepAlive();
  215.                     doPlay();
  216.                 }
  217.         }
  218.  
  219.         protected void resetButton_Click(object sender, EventArgs e)
  220.         {
  221.             //Load settings
  222.             guideParams = Global.Settings;
  223.  
  224.             //Instantiate a VLC instance defaulted to correct profile
  225.             VLCCommon VLC = new VLCCommon(vlcProfile);
  226.  
  227.             //Web Streamer VLC Common Class
  228.             streamPlayer.Text = VLC.getPlayer();
  229.  
  230.             //Need to set the appropriate pre-configed options on the page based on player selection
  231.             streamPlayer_SelectedIndexChanged(null, null);
  232.  
  233.             externalPlayer.Checked = VLC.strmExternal;
  234.             streamPort.Text = VLC.getStrmPort().ToString();
  235.             streamBuffer.Text = VLC.getStrmBuffer().ToString();
  236.             streamPriority.Text = VLC.getStrmPriority();
  237.             streamBitRate.Text = VLC.getStrmBitRate().ToString();
  238.             streamVideoSizeOpt.SelectedValue = VLC.getStrmVideoSizeOpt();
  239.  
  240.             if (streamVideoSizeOpt.SelectedValue == "preset")
  241.             {
  242.                 streamVideoScaleSize.Visible = false;
  243.                 streamVideoSize.Visible = true;
  244.             }
  245.             else
  246.             {
  247.                 streamVideoSizeOpt.SelectedValue = "scale";
  248.                 streamVideoSize.Visible = false;
  249.                 streamVideoScaleSize.Visible = true;
  250.             }
  251.  
  252.             streamVideoSize.Text = VLC.getStrmVideoSize();
  253.             streamVideoScaleSize.Text = VLC.getStrmVideoScale();
  254.             streamSetting.SelectedValue = VLC.getStrmSetting();
  255.  
  256.             if (VLC.getStrmSetting() == "manual")
  257.             {
  258.                 preConfigMessage.Visible = false;
  259.                 manualOptions.Visible = true;
  260.  
  261.                 strmMux.SelectedValue = VLC.getStrmMux();
  262.                 strmVideo.SelectedValue = VLC.getStrmVideo();
  263.                 strmAudio.SelectedValue = VLC.getStrmAudio();
  264.                 strmAudoBitrate.SelectedValue = VLC.getStrmAudioBitRate();
  265.                 strmAudioChannels.SelectedValue = VLC.getStrmAudioChannels();
  266.                 strmVencoder.SelectedValue = VLC.getStrmVEncoder();
  267.                 if (VLC.getStrmVEncoder() == "h264")
  268.                 {
  269.                     H264.Visible = true;
  270.                     
  271.                     //Web Streamer H264 Video Encoder Class.  Instantiate to appropriate profile
  272.                     H264Encoder H264Enc = new H264Encoder(vlcProfile);
  273.  
  274.                     strmH264KeyInt.Text = H264Enc.getH264KeyInt();
  275.                     strmH264IDRInt.Text = H264Enc.getH264IDRInt();
  276.                     strmH264BFrames.Text = H264Enc.getH264BFrames();
  277.                     strmH264QuantizerParam.Text = H264Enc.getH264QuantizerParam();
  278.                     strmH264QuantizerMax.Text = H264Enc.getH264QuantizerMax();
  279.                     strmH264QuantizerMin.Text = H264Enc.getH264QuantizerMin();
  280.                     strmH264CABAC.Checked = H264Enc.getH264CABAC();
  281.                     strmH264LoopFilter.Checked = H264Enc.getH264LoopFilter();
  282.                     strmH264Analyse.Checked = H264Enc.getH264Analyse();
  283.                     strmH264FrameRef.Text = H264Enc.getH264FrameRef();
  284.                     strmH264Adapt.Text = H264Enc.getH264Adapt();
  285.                     strmH264Me.Text = H264Enc.getH264Me();
  286.                     strmH264SubME.Text = H264Enc.getH264SubME();
  287.                     strmH264ChromaME.Text = H264Enc.getH264ChromaME();
  288.                     strmH264MERange.Text = H264Enc.getH264MERange();
  289.                 }
  290.                 else
  291.                 {
  292.                     H264.Visible = false;
  293.                 }
  294.             }
  295.             else
  296.             {
  297.                 preConfigMessage.Visible = true;
  298.                 manualOptions.Visible = false;
  299.                 H264.Visible = false;
  300.             }
  301.         }
  302.  
  303.         private int GetVlcProfile()
  304.         {
  305.             //Determine if VLC object should be defualted to profile 1(video) or 2(audio)
  306.             if (Request.Params["playerType"] != null)
  307.             {
  308.                 vlcProfile = Convert.ToInt16(Request.Params["playerType"]);
  309.             }
  310.             else
  311.             {
  312.                 vlcProfile = 1;
  313.             }
  314.             return vlcProfile;
  315.         }
  316.  
  317.         protected void playerOptsButton_Click(object sender, EventArgs e)
  318.         {
  319.             playerOptions.Visible = true;
  320.             if (Request.Params["type"] == null)
  321.             {
  322.                 if (vlcProfile == 1)
  323.                 {
  324.                     SETTINGS_HEADER.InnerHtml = "Player Options - Video Library";
  325.                 }
  326.                 else
  327.                 {
  328.                     SETTINGS_HEADER.InnerHtml = "Player Options - Music Library";
  329.                 }
  330.             }
  331.             else
  332.             {
  333.                 if (Request.Params["type"] == "sn")
  334.                 {
  335.                     SETTINGS_HEADER.InnerHtml = "Player Options - Stream Now";
  336.                 }
  337.                 else
  338.                 {
  339.                     SETTINGS_HEADER.InnerHtml = "Player Options - Manage Recordings";
  340.                 }
  341.             }
  342.             transcodeOptions.Visible = false;
  343.             MusicVideoControls.Visible = false;
  344.  
  345.             hlSubmit_Click(null, null);
  346.             resetButton_Click(null, null);
  347.         }
  348.  
  349.         protected void transOptsButton_Click(object sender, EventArgs e)
  350.         {
  351.             playerOptions.Visible = false;
  352.             MusicVideoControls.Visible = false;
  353.             transcodeOptions.Visible = true;
  354.             if (Request.Params["type"] == null)
  355.             {
  356.                 if (vlcProfile == 1)
  357.                 {
  358.                     SETTINGS_HEADER.InnerHtml = "Transcode Options - Video Library";
  359.                 }
  360.                 else
  361.                 {
  362.                     SETTINGS_HEADER.InnerHtml = "Transcode Options - Music Library";
  363.                 }
  364.             }
  365.             else
  366.             {
  367.                 if (Request.Params["type"] == "sn")
  368.                 {
  369.                     SETTINGS_HEADER.InnerHtml = "Transcode Options - Stream Now";
  370.                 }
  371.                 else
  372.                 {
  373.                     SETTINGS_HEADER.InnerHtml = "Transcode Options - Manage Recordings";
  374.                 }
  375.             }
  376.             if (streamSetting.SelectedValue != "manual")
  377.             {
  378.                 manualOptions.Visible = false;
  379.             }
  380.             else
  381.             {
  382.                 manualOptions.Visible = true;
  383.             }
  384.             hlSubmit_Click(null, null);
  385.             resetButton_Click(null, null);
  386.         }
  387.  
  388.         protected void hlSubmit_Click(object sender, EventArgs e)
  389.         {
  390.             guideParams = Global.Settings;
  391.  
  392.             //Determine correct VLC Profile
  393.             vlcProfile = GetVlcProfile();
  394.  
  395.             if (vlcProfile != 2)
  396.             {
  397.                 guideParams.strmPlayer = streamPlayer.Text;
  398.                 guideParams.strmExternal = externalPlayer.Checked;
  399.                 guideParams.strmPort = Convert.ToInt32(streamPort.Text);
  400.                 guideParams.strmBuffer = Convert.ToInt32(streamBuffer.Text);
  401.                 guideParams.strmPriority = streamPriority.Text;
  402.                 guideParams.strmBitRate = Convert.ToInt32(streamBitRate.Text);
  403.                 guideParams.strmVideoSizeOpt = streamVideoSizeOpt.Text;
  404.                 guideParams.strmVideoSize = streamVideoSize.Text;
  405.                 CultureInfo culture = new CultureInfo("en-US");
  406.                 guideParams.strmVideoScaleSize =
  407.                     String.Format("{0:00.00}",
  408.                                   decimal.Parse(streamVideoScaleSize.Text.Replace(',', '.'),
  409.                                                 NumberStyles.AllowDecimalPoint, culture)).Replace(
  410.                         ',', '.');
  411.                 streamVideoScaleSize.Text = guideParams.strmVideoScaleSize;
  412.  
  413.                 if (streamVideoSizeOpt.SelectedValue == "preset")
  414.                 {
  415.                     streamVideoScaleSize.Visible = false;
  416.                     streamVideoSize.Visible = true;
  417.                 }
  418.                 else
  419.                 {
  420.                     streamVideoSize.Visible = false;
  421.                     streamVideoScaleSize.Visible = true;
  422.                 }
  423.  
  424.                 guideParams.strmSetting = streamSetting.Text;
  425.  
  426.                 if (streamSetting.Text == "manual")
  427.                 {
  428.                     preConfigMessage.Visible = false;
  429.                     manualOptions.Visible = true;
  430.  
  431.                     guideParams.strmMux = strmMux.SelectedValue;
  432.                     guideParams.strmVideo = strmVideo.SelectedValue;
  433.                     guideParams.strmAudio = strmAudio.SelectedValue;
  434.                     guideParams.strmAudoBitrate = strmAudoBitrate.SelectedValue;
  435.                     guideParams.strmAudioChannels = strmAudioChannels.SelectedValue;
  436.                     guideParams.strmVEncoder = strmVencoder.SelectedValue;
  437.  
  438.                     if (strmVencoder.SelectedValue == "h264")
  439.                     {
  440.                         H264.Visible = true;
  441.                         guideParams.strmH264KeyInt = strmH264KeyInt.Text;
  442.                         guideParams.strmH264IDRInt = strmH264IDRInt.Text;
  443.                         guideParams.strmH264BFrames = strmH264BFrames.Text;
  444.                         guideParams.strmH264QuantizerParam = strmH264QuantizerParam.Text;
  445.                         guideParams.strmH264QuantizerMax = strmH264QuantizerMax.Text;
  446.                         guideParams.strmH264QuantizerMin = strmH264QuantizerMin.Text;
  447.                         guideParams.strmH264CABAC = strmH264CABAC.Checked;
  448.                         guideParams.strmH264LoopFilter = strmH264LoopFilter.Checked;
  449.                         guideParams.strmH264Analyse = strmH264Analyse.Checked;
  450.                         guideParams.strmH264FrameRef = strmH264FrameRef.Text;
  451.                         guideParams.strmH264Adapt = strmH264Adapt.Text;
  452.                         guideParams.strmH264Me = strmH264Me.Text;
  453.                         guideParams.strmH264SubME = strmH264SubME.Text;
  454.                         guideParams.strmH264ChromaME = strmH264ChromaME.Text;
  455.                         guideParams.strmH264MERange = strmH264MERange.Text;
  456.                     }
  457.                     else
  458.                     {
  459.                         H264.Visible = false;
  460.                     }
  461.                 }
  462.                 else
  463.                 {
  464.                     preConfigMessage.Visible = true;
  465.                     manualOptions.Visible = false;
  466.                     H264.Visible = false;
  467.                 }
  468.             }
  469.             else
  470.             {
  471.                 guideParams.strmPlayer2 = streamPlayer.Text;
  472.                 guideParams.strmExternal2 = externalPlayer.Checked;
  473.                 guideParams.strmPort2 = Convert.ToInt32(streamPort.Text);
  474.                 guideParams.strmBuffer2 = Convert.ToInt32(streamBuffer.Text);
  475.                 guideParams.strmPriority2 = streamPriority.Text;
  476.                 guideParams.strmBitRate2 = Convert.ToInt32(streamBitRate.Text);
  477.                 guideParams.strmVideoSizeOpt2 = streamVideoSizeOpt.Text;
  478.                 guideParams.strmVideoSize2 = streamVideoSize.Text;
  479.                 CultureInfo culture = new CultureInfo("en-US");
  480.                 guideParams.strmVideoScaleSize2 =
  481.                     String.Format("{0:00.00}",
  482.                                   decimal.Parse(streamVideoScaleSize.Text.Replace(',', '.'),
  483.                                                 NumberStyles.AllowDecimalPoint, culture)).Replace(
  484.                         ',', '.');
  485.                 streamVideoScaleSize.Text = guideParams.strmVideoScaleSize2;
  486.  
  487.                 if (streamVideoSizeOpt.SelectedValue == "preset")
  488.                 {
  489.                     streamVideoScaleSize.Visible = false;
  490.                     streamVideoSize.Visible = true;
  491.                 }
  492.                 else
  493.                 {
  494.                     streamVideoSize.Visible = false;
  495.                     streamVideoScaleSize.Visible = true;
  496.                 }
  497.  
  498.                 guideParams.strmSetting2 = streamSetting.Text;
  499.  
  500.                 if (streamSetting.Text == "manual")
  501.                 {
  502.                     preConfigMessage.Visible = false;
  503.                     manualOptions.Visible = true;
  504.  
  505.                     guideParams.strmMux2 = strmMux.SelectedValue;
  506.                     guideParams.strmVideo2 = strmVideo.SelectedValue;
  507.                     guideParams.strmAudio2 = strmAudio.SelectedValue;
  508.                     guideParams.strmAudoBitrate2 = strmAudoBitrate.SelectedValue;
  509.                     guideParams.strmAudioChannels2 = strmAudioChannels.SelectedValue;
  510.                     guideParams.strmVEncoder2 = strmVencoder.SelectedValue;
  511.  
  512.                     if (strmVencoder.SelectedValue == "h264")
  513.                     {
  514.                         H264.Visible = true;
  515.                         guideParams.strmH264KeyInt2 = strmH264KeyInt.Text;
  516.                         guideParams.strmH264IDRInt2 = strmH264IDRInt.Text;
  517.                         guideParams.strmH264BFrames2 = strmH264BFrames.Text;
  518.                         guideParams.strmH264QuantizerParam2 = strmH264QuantizerParam.Text;
  519.                         guideParams.strmH264QuantizerMax2 = strmH264QuantizerMax.Text;
  520.                         guideParams.strmH264QuantizerMin2 = strmH264QuantizerMin.Text;
  521.                         guideParams.strmH264CABAC2 = strmH264CABAC.Checked;
  522.                         guideParams.strmH264LoopFilter2 = strmH264LoopFilter.Checked;
  523.                         guideParams.strmH264Analyse2 = strmH264Analyse.Checked;
  524.                         guideParams.strmH264FrameRef2 = strmH264FrameRef.Text;
  525.                         guideParams.strmH264Adapt2 = strmH264Adapt.Text;
  526.                         guideParams.strmH264Me2 = strmH264Me.Text;
  527.                         guideParams.strmH264SubME2 = strmH264SubME.Text;
  528.                         guideParams.strmH264ChromaME2 = strmH264ChromaME.Text;
  529.                         guideParams.strmH264MERange2 = strmH264MERange.Text;
  530.                     }
  531.                     else
  532.                     {
  533.                         H264.Visible = false;
  534.                     }
  535.                 }
  536.                 else
  537.                 {
  538.                     preConfigMessage.Visible = true;
  539.                     manualOptions.Visible = false;
  540.                     H264.Visible = false;
  541.                 }
  542.             }
  543.  
  544.             Global.Settings.Save();
  545.  
  546.         }
  547.  
  548.         private void getTheme()
  549.         {
  550.             string theme = Convert.ToString(Session["theme"]);
  551.  
  552.             if (theme != null && theme != "")
  553.             {
  554.                 return;
  555.             }
  556.             else
  557.             {
  558.                 HttpCookie cookie = Request.Cookies["theme"];
  559.                 if (cookie != null && cookie.Value.Length > 0)
  560.                 {
  561.                     theme = cookie.Value;
  562.                 }
  563.                 else
  564.                 {
  565.                     theme = "Default";
  566.                 }
  567.                 Session["theme"] = "themes/" + theme;
  568.                 return;
  569.             }
  570.         }
  571.  
  572.         protected void streamPlayer_SelectedIndexChanged(object sender, EventArgs e)
  573.         {
  574.             if (IsPostBack)
  575.             {
  576.                 if (streamPlayer.SelectedValue == "dnld")
  577.                 {
  578.                     string holdSelection = streamSetting.SelectedValue;
  579.                     setDownloadTransOptions();
  580.  
  581.                     try
  582.                     {
  583.                         streamSetting.SelectedValue = holdSelection;
  584.                     }
  585.                     catch
  586.                     {
  587.                         streamSetting.Items[0].Selected = true;
  588.                     }
  589.  
  590.  
  591.                     hlSubmit_Click(null, null);
  592.                 }
  593.                 else
  594.                 {
  595.                     string holdSelection = streamSetting.SelectedValue;
  596.                     setNonDownloadTransOptions();
  597.  
  598.                     try
  599.                     {
  600.                         streamSetting.SelectedValue = holdSelection;
  601.                     }
  602.                     catch
  603.                     {
  604.                         streamSetting.Items[0].Selected = true;
  605.                     }
  606.  
  607.                     hlSubmit_Click(null, null);
  608.                 }
  609.             }
  610.         }
  611.  
  612.         private void setDownloadTransOptions()
  613.         {
  614.             streamSetting.Items.Clear();
  615.             streamSetting.Items.Add("MP4V/MPGA/MPEG-TS");
  616.             streamSetting.Items[0].Value = "dvs0";
  617.             streamSetting.Items[0].Selected = true;
  618.             streamSetting.Items.Add("MP2V/MPGA/MPEG-TS");
  619.             streamSetting.Items[1].Value = "dvs1";
  620.             streamSetting.Items.Add("MP1V/MPGA/MPEG-TS");
  621.             streamSetting.Items[2].Value = "dvs2";
  622.             streamSetting.Items.Add("Manual Options");
  623.             streamSetting.Items[3].Value = "manual";
  624.         }
  625.  
  626.         private void setNonDownloadTransOptions()
  627.         {
  628.             streamSetting.Items.Clear();
  629.             streamSetting.Items.Add("MP4V/MP4A/MPEG-TS");
  630.             streamSetting.Items[0].Value = "0";
  631.             streamSetting.Items.Add("WMV/MP4A/MPEG-TS");
  632.             streamSetting.Items[1].Value = "1";
  633.             streamSetting.Items.Add("WMV/MP3/ASF");
  634.             streamSetting.Items[2].Value = "2";
  635.             streamSetting.Items.Add("H264/MP4A/MPEG-TS");
  636.             streamSetting.Items[3].Value = "3";
  637.             streamSetting.Items.Add("Manual Options");
  638.             streamSetting.Items[4].Value = "manual";
  639.         }
  640.  
  641.         protected void externalPlayer_CheckedChanged(object sender, EventArgs e)
  642.         {
  643.             if (IsPostBack)
  644.             {
  645.                 hlSubmit_Click(null, null);
  646.                 resetButton_Click(null, null);
  647.             }
  648.         }
  649.  
  650.  
  651.         private string GetFilename()
  652.         {
  653.             //Setup schedule to obtain program info to stream
  654.             Schedule scheduleHelper = Global.Schedule;
  655.             string filename = "";
  656.  
  657.             //Search/pull the filename of the passed recording
  658.             if (Request.Params["rid"] != null)
  659.             {
  660.                 ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  661.                 if (scheduledRecording != null)
  662.                 {
  663.                     filename = scheduledRecording.getFileName();
  664.                 }
  665.             }
  666.             else
  667.             {
  668.                 //We are accessing either a Music of Video Library item
  669.                 if (Request.Params["mvid"] != null)
  670.                 {
  671.                     string path = (string)PublicDownload.Deseralize(Request.Params["mvid"]);
  672.                     filename = Library.GetRealPath(path);
  673.                     Logger.Info("***********************");
  674.                     Logger.Info("File Name Deserialized: " + filename);
  675.                 }
  676.                 else
  677.                 {
  678.                     //We are accessing an entire directory of music or videos
  679.                     if (Request.Params["mid"] != null)
  680.                     {
  681.                         string path = (string)PublicDownload.Deseralize((string)Request.Params["mid"]);
  682.                         string tmpDir = Environment.GetEnvironmentVariable("ALLUSERSPROFILE");
  683.                         filename = Path.Combine(tmpDir, Download.streamLibraryFolder(Request, path));
  684.                         Logger.Info("***********************");
  685.                         Logger.Info("File Location Deserialized: " + filename);
  686.                     }
  687.                 }
  688.             }
  689.             return filename;
  690.         }
  691.  
  692.         protected void launchPlayer_Click(object sender, System.EventArgs e)
  693.         {
  694.             //Set the parameter variables for the plugin players
  695.             string vsize;
  696.             if (vlcProfile == 1)
  697.             {
  698.                 vsize = guideParams.strmVideoSize;
  699.             }
  700.             else
  701.             {
  702.                vsize = guideParams.strmVideoSize2;
  703.             }
  704.             VLCCommon VLC = new VLCCommon(vlcProfile);
  705.             string width = " WIDTH=\"320\"";
  706.             string heigth = " HEIGHTH=\"213\"";
  707.             EMBEDDED_PLAYER.InnerHtml = "";
  708.             getServerAddress();
  709.  
  710.             if (VLC.strmPlayer != "dnld")
  711.             {
  712.                 if ((vlcProfile == 1 && !guideParams.strmExternal) || (vlcProfile == 2 && !guideParams.strmExternal2))
  713.                 {
  714.                     pluginArea.Visible = true;
  715.                     launchPlugin(width, heigth);
  716.                 }
  717.                 else
  718.                 {
  719.                     pluginArea.Visible = false;
  720.                     //Launch VLC External player
  721.                     if ((vlcProfile == 1 && guideParams.strmPlayer == "vlc") ||
  722.                         (vlcProfile == 2 && guideParams.strmPlayer2 == "vlc"))
  723.                     {
  724.                         Response.AddHeader("Content-Type", "video/mpeg4");
  725.                         Response.AddHeader("Content-Disposition", "attachment; filename=\"stream.vlc\"");
  726.                         Response.Write("#EXTM3U\r\n");
  727.                         Response.Write("http://" + getServerAddress() + "\n");
  728.                         Response.End();
  729.                     }
  730.                     else
  731.                         //Launch Windows Media Player (as long as ASF is associated to Windows Media)
  732.                     {
  733.                         Response.AddHeader("Content-Type", "video/x-ms-asf");
  734.                         Response.AddHeader("Content-Disposition", "attachment; filename=\"stream.asx\"");
  735.                         Response.Write("http://" + getServerAddress() + "\n");
  736.                         Response.End();
  737.                     }
  738.                 }
  739.             }
  740.             else
  741.             {
  742.                 Response.AddHeader("Content-Type", "text/plain");
  743.                 string filename = GetFilename();
  744.                 Response.AddHeader("Content-Disposition", "attachment; filename=\"download_stream.bat\"");
  745.                 string dnldFile = " --sout file/raw:\"%HOMEDRIVE%%HOMEPATH%\\" + filename.Substring(filename.LastIndexOf("\\") + 1, ((filename.Length - 1) - filename.LastIndexOf("\\")));
  746.  
  747.                 //set file extension of downloaded file based on profile
  748.                 switch (vlcProfile)
  749.                 {
  750.                     //Profile 1 is the video profile
  751.                     case 1:
  752.                         switch (streamSetting.SelectedValue)
  753.                         {
  754.                             case "0":
  755.                                 dnldFile += ".mpg\"";
  756.                                 break;
  757.                             case "1":
  758.                                 dnldFile += ".wmv\"";
  759.                                 break;
  760.                             case "2":
  761.                                 dnldFile += ".wmv\"";
  762.                                 break;
  763.                             case "3":
  764.                                 dnldFile += ".mpg\"";
  765.                                 break;
  766.                             case "manual":
  767.                                 switch (VLC.strmVideo)
  768.                                 {
  769.                                     case "WMV1":
  770.                                         dnldFile += ".wmv\"";
  771.                                         break;
  772.                                     case "WMV2":
  773.                                         dnldFile += ".wmv\"";
  774.                                         break;
  775.                                     default:
  776.                                         dnldFile += ".mpg\"";
  777.                                         break;
  778.                                 }
  779.                                 break;
  780.                             default:
  781.                                 dnldFile += ".mpg\"";
  782.                                 break;
  783.                         }
  784.                         break;
  785.                     //Profile 2 is the audio profile
  786.                     case 2:
  787.                         switch (streamSetting.SelectedValue)
  788.                         {
  789.                             //since all the pre-config settings result in .mpg extension we only need to look at
  790.                             //the manaul setting
  791.                             case "manual":
  792.                                 switch (VLC.strmAudio)
  793.                                 {
  794.                                     case "mp4a":
  795.                                         dnldFile += ".mp4\"";
  796.                                         break;
  797.                                     case "mp3":
  798.                                         dnldFile += ".mp3\"";
  799.                                         break;
  800.                                     default:
  801.                                         dnldFile += ".mpg\"";
  802.                                         break;
  803.                                 }
  804.                                 break;
  805.                             default:
  806.                                 dnldFile += ".mpg\"";
  807.                                 break;
  808.                         }
  809.                         break;
  810.                     //Catch all.....we will handle the file as Profile 1 (video)
  811.                     default:
  812.                         switch (streamSetting.SelectedValue)
  813.                         {
  814.                             case "0":
  815.                                 dnldFile += ".mpg\"";
  816.                                 break;
  817.                             case "1":
  818.                                 dnldFile += ".wmv\"";
  819.                                 break;
  820.                             case "2":
  821.                                 dnldFile += ".wmv\"";
  822.                                 break;
  823.                             case "3":
  824.                                 dnldFile += ".mpg\"";
  825.                                 break;
  826.                             case "manual":
  827.                                 switch (VLC.strmVideo)
  828.                                 {
  829.                                     case "WMV1":
  830.                                         dnldFile += ".wmv\"";
  831.                                         break;
  832.                                     case "WMV2":
  833.                                         dnldFile += ".wmv\"";
  834.                                         break;
  835.                                     default:
  836.                                         dnldFile += ".mpg\"";
  837.                                         break;
  838.                                 }
  839.                                 break;
  840.                             default:
  841.                                 dnldFile += ".mpg\"";
  842.                                 break;
  843.                         }
  844.                         break;
  845.                 }
  846.                 //Response.Write("\"" + VLC.getVLCLoc() + "vlc.exe\" " + "http://" + serverAddr + " --sout file/raw:\"" + filename.Substring(filename.LastIndexOf("\\") + 1, ((filename.Length - 1) - filename.LastIndexOf("\\"))) + ".mpg\"");
  847.                 Response.Write("\"" + VLC.getVLCLoc() + "vlc.exe\" " + "http://" + serverAddr + dnldFile);
  848.                 Response.End();
  849.             }
  850.         }
  851.         
  852.         private void launchPlugin(string width, string heigth)
  853.         {
  854.             //Windows Media Plugin
  855.             if ((vlcProfile == 1 && guideParams.strmPlayer == "wmp") || (vlcProfile != 1 && guideParams.strmPlayer2 == "wmp"))
  856.             {
  857.                 //Media Player for non IE browser
  858.                 if (Request.ServerVariables["HTTP_USER_AGENT"].IndexOf("MSIE") < 1)
  859.                 {
  860.                     EMBEDDED_PLAYER.InnerHtml = " <EMBED TYPE=\"application/x-mplayer2\"";
  861.                     EMBEDDED_PLAYER.InnerHtml += " AutoStart=\"true\"";
  862.                     EMBEDDED_PLAYER.InnerHtml += " NAME=\"video1\"";
  863.                     EMBEDDED_PLAYER.InnerHtml += " ShowControls=\"1\" ShowStatusBar=\"1\" AutoSize=\"false\" loop=\"false\" EnableContextMenu=\"0\" DisplaySize=\"0\"";
  864.                     EMBEDDED_PLAYER.InnerHtml += " SRC=\"http://" + getServerAddress() + "\"";
  865.                     EMBEDDED_PLAYER.InnerHtml += width;
  866.                     EMBEDDED_PLAYER.InnerHtml += heigth;
  867.                     EMBEDDED_PLAYER.InnerHtml += " </EMBED>";
  868.                 }
  869.                 else
  870.                 //Media Player for IE browser
  871.                 {
  872.                     EMBEDDED_PLAYER.InnerHtml = "<OBJECT id=\"VIDEO\" " + width + "\" " + heigth + "\"";
  873.                     EMBEDDED_PLAYER.InnerHtml += " CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"";
  874.                     EMBEDDED_PLAYER.InnerHtml += "type=\"application/x-oleobject\">\n";
  875.                     EMBEDDED_PLAYER.InnerHtml += "<PARAM NAME=\"URL\" VALUE=\"http://" + getServerAddress() + "\">\n";
  876.                     EMBEDDED_PLAYER.InnerHtml += "<PARAM NAME=\"AutoStart\" VALUE=\"True\">\n";
  877.                     EMBEDDED_PLAYER.InnerHtml += "<PARAM name=\"uiMode\" value=\"mini\">\n";
  878.                     EMBEDDED_PLAYER.InnerHtml += "</OBJECT>\n";
  879.                 }
  880.  
  881.             }
  882.             //VLC Plugin being displayed in IE
  883.             else if (Request.ServerVariables["HTTP_USER_AGENT"].IndexOf("MSIE") > 0)
  884.             {
  885.                 EMBEDDED_PLAYER.InnerHtml += " <OBJECT id=\"video1\" codeBase=\"http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab\" " + width + " " + heigth + " classid=\"clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8\" events=\"True\" >\n";
  886.                 EMBEDDED_PLAYER.InnerHtml += " <PARAM NAME=\"AutoLoop\" VALUE=\"FALSE\">\n";
  887.                 EMBEDDED_PLAYER.InnerHtml += " <PARAM NAME=\"AutoPlay\" VALUE=\"TRUE\">\n";
  888.                 EMBEDDED_PLAYER.InnerHtml += " <PARAM NAME=\"MRL\" VALUE=\"\">";
  889.                 EMBEDDED_PLAYER.InnerHtml += " <PARAM NAME=\"ShowDisplay\" VALUE=\"TRUE\">\n";
  890.                 EMBEDDED_PLAYER.InnerHtml += " </OBJECT>\n";
  891.                 //AddPlayerScript();
  892.             }
  893.             //VLC Plugin being displayed in a non-IE browser
  894.             else
  895.             {
  896.                 EMBEDDED_PLAYER.InnerHtml += " <embed type=\"application/x-vlc-plugin\" name=\"video1\" autoplay=\"yes\" loop=\"no\" " + width + " " + heigth;
  897.                 EMBEDDED_PLAYER.InnerHtml += " target=\"http://" + getServerAddress() + "\">";
  898.                 //AddPlayerScript();
  899.             }
  900.         }
  901.        
  902.         protected string getServerAddress()
  903.         {
  904.             serverAddr = string.Empty;
  905.  
  906.             //Get the server IP
  907.             string serverIP = Request.ServerVariables["http_host"];
  908.             int index = serverIP.IndexOf(":");
  909.             if (index > -1)
  910.                 serverIP = serverIP.Substring(0, index).Trim();
  911.             if ((serverIP == null) || (serverIP.Length < 1))
  912.                 serverIP = getIP();
  913.  
  914.             //Create the address the stream will be available on
  915.             serverAddr = serverIP + ":" + guideParams.strmPort;
  916.  
  917.             return (serverAddr);
  918.         }
  919.  
  920.         protected string getIP()
  921.         {
  922.             //Alternative method for obtaining external IP if it can not be obtained by Request.Servervariables
  923.             System.Net.WebClient wclient = new System.Net.WebClient();
  924.  
  925.             wclient.DownloadFile("http://www.whatismyip.com/", Request.MapPath("ip.txt"));
  926.  
  927.             FileStream FS = new FileStream(Request.MapPath("ip.txt"), FileMode.Open);
  928.             StreamReader SR = new StreamReader(FS);
  929.  
  930.             string entirefile = SR.ReadToEnd();
  931.             int startIndex = entirefile.IndexOf("<h1>Your IP");
  932.             int endIndex = entirefile.IndexOf("</", startIndex);
  933.  
  934.             string restOfTheLine = entirefile.Substring(startIndex + 15, (endIndex - startIndex - 15));
  935.             string theIp = restOfTheLine.TrimEnd("<>brh1 ".ToCharArray());
  936.             SR.Close();
  937.             FS.Close();
  938.  
  939.             File.Delete(Request.MapPath("ip.txt"));
  940.             return theIp.Trim();
  941.         }
  942.  
  943.         protected void doPlay()
  944.         {
  945.             //Process to launch VLC on server to stream video
  946.  
  947.             //Setup schedule to obtain program info to stream
  948.             Schedule scheduleHelper = Global.Schedule;
  949.             string filename = GetFilename();
  950.  
  951.             //Develop list of arguments to be passed to VLC on the server
  952.             string args;
  953.             
  954.             //Instantiate a VLC instance defaulted to correct profile
  955.             VLCCommon VLC = new VLCCommon(vlcProfile);
  956.  
  957.             if (VLC.getStrmSetting() == "manual")
  958.             {
  959.                 if (VLC.getStrmVEncoder() == "h264")
  960.                 {
  961.                     //Instantiate H264 object to appropriate profile
  962.                     H264Encoder H264Enc = new H264Encoder(vlcProfile);
  963.                     args = VLC.genCommandLine(filename, VLC, H264Enc);
  964.                 }
  965.                 else
  966.                 {
  967.                     args = VLC.genCommandLine(filename, VLC);
  968.                 }
  969.             }
  970.             else
  971.             {
  972.                 args = VLC.genCommandLine(filename, VLC.getStrmSetting(), VLC.getStrmVideoSize(), VLC.getStrmMux(), VLC.getStrmBitRate(),
  973.                                           VLC.getStrmPort());
  974.             }
  975.  
  976.             //Log what is being started on the server
  977.             Logger.Info("***********************");
  978.             if (vlcProfile == 1)
  979.             {
  980.                 Logger.Info("VLC Path= " + guideParams.strmVLCLoc); 
  981.             }
  982.             else
  983.             {
  984.                 Logger.Info("VLC Path= " + guideParams.strmVLCLoc2);
  985.             }
  986.             
  987.             Logger.Info("Args= " + args);
  988.  
  989.             //Build the process that will run VLC on the server
  990.             psi = new System.Diagnostics.ProcessStartInfo(VLC.getVLCLoc() + "vlc.exe", args);
  991.             psi.UseShellExecute = false;
  992.             psi.RedirectStandardError = false;
  993.             psi.RedirectStandardInput = false;
  994.             psi.RedirectStandardOutput = false;
  995.  
  996.             //Start the VLC process on the server
  997.             proc = System.Diagnostics.Process.Start(psi);
  998.  
  999.             //Set the priority of the started process based off of user configuration
  1000.             switch (VLC.getStrmPriority().ToUpper())
  1001.             {
  1002.                 case "BELOWNORMAL":
  1003.                     proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
  1004.                     break;
  1005.                 case "ABOVENORMAL":
  1006.                     proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal;
  1007.                     break;
  1008.                 case "NORMAL":
  1009.                     proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
  1010.                     break;
  1011.                 case "HIGH":
  1012.                     proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
  1013.                     break;
  1014.                 default:
  1015.                     proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
  1016.                     break;
  1017.             }
  1018.  
  1019.         }
  1020.  
  1021.         protected void killServerStream(object sender, EventArgs e)
  1022.         {
  1023.             killVLC();
  1024.             pluginArea.Visible = false;
  1025.             streamMessage.InnerHtml = "";
  1026.             EMBEDDED_PLAYER.InnerHtml = "";
  1027.         }
  1028.  
  1029.         //Method that makes VLC on the server skip forward 10 seconds on the currently playing item
  1030.         protected static void skipForwardStream(object sender, EventArgs e)
  1031.         {
  1032.             StreamerPost strmPost = new StreamerPost();
  1033.             strmPost.Url = "http://localhost:8080/";
  1034.             strmPost.PostItems.Add("seek_value", "+10sec");
  1035.             strmPost.PostItems.Add("control", "seek");
  1036.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1037.             string result = strmPost.Post();
  1038.             result = String.Empty;
  1039.         }
  1040.  
  1041.         //Method that makes VLC on the server skip backward 10 seconds on the currently playing item
  1042.         protected static void skipBackwardStream(object sender, EventArgs e)
  1043.         {
  1044.             StreamerPost strmPost = new StreamerPost();
  1045.             strmPost.Url = "http://localhost:8080/";
  1046.             strmPost.PostItems.Add("seek_value", "-10sec");
  1047.             strmPost.PostItems.Add("control", "seek");
  1048.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1049.             string result = strmPost.Post();
  1050.             result = String.Empty;
  1051.         }
  1052.  
  1053.         //Method that makes VLC on the server skip to the next item in the playlist
  1054.         protected static void nextStream(object sender, EventArgs e)
  1055.         {
  1056.             StreamerPost strmPost = new StreamerPost();
  1057.             strmPost.Url = "http://localhost:8080/";
  1058.             strmPost.PostItems.Add("control", "next");
  1059.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1060.             string result = strmPost.Post();
  1061.             result = String.Empty;
  1062.         }
  1063.  
  1064.         //Method that makes VLC on the server skip back to the previous item in the playlist
  1065.         protected static void previousStream(object sender, EventArgs e)
  1066.         {
  1067.             StreamerPost strmPost = new StreamerPost();
  1068.             strmPost.Url = "http://localhost:8080/";
  1069.             strmPost.PostItems.Add("control", "previous");
  1070.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1071.             string result = strmPost.Post();
  1072.             result = String.Empty;
  1073.         }
  1074.  
  1075.         //Method that makes VLC on the server stop playing
  1076.         protected static void stopStream(object sender, EventArgs e)
  1077.         {
  1078.             StreamerPost strmPost = new StreamerPost();
  1079.             strmPost.Url = "http://localhost:8080/";
  1080.             strmPost.PostItems.Add("control", "stop");
  1081.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1082.             string result = strmPost.Post();
  1083.             result = String.Empty;
  1084.         }
  1085.  
  1086.         //Method that makes VLC on the server start to play the playlist
  1087.         protected static void playStream(object sender, EventArgs e)
  1088.         {
  1089.             StreamerPost strmPost = new StreamerPost();
  1090.             strmPost.Url = "http://localhost:8080/";
  1091.             strmPost.PostItems.Add("control", "play");
  1092.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1093.             string result = strmPost.Post();
  1094.             result = String.Empty;
  1095.         }
  1096.  
  1097.         //Method that makes VLC on the server pause playing of the currently playing item
  1098.         protected static void pauseStream(object sender, EventArgs e)
  1099.         {
  1100.             StreamerPost strmPost = new StreamerPost();
  1101.             strmPost.Url = "http://localhost:8080/";
  1102.             strmPost.PostItems.Add("control", "pause");
  1103.             strmPost.Type = StreamerPost.PostTypeEnum.Get;
  1104.             string result = strmPost.Post();
  1105.             result = String.Empty;
  1106.         }
  1107.  
  1108.         //Method that Kills the VLC process on the server
  1109.         protected void stopStreamer(object sender, EventArgs e)
  1110.         {
  1111.             settingsButtons.Visible = true;
  1112.  
  1113.             playerOptions.Visible = true;
  1114.             if (Request.Params["type"] == null)
  1115.             {
  1116.                 if (vlcProfile == 1)
  1117.                 {
  1118.                     SETTINGS_HEADER.InnerHtml = "Player Options - Video Library";
  1119.                 }
  1120.                 else
  1121.                 {
  1122.                     SETTINGS_HEADER.InnerHtml = "Player Options - Music Library";
  1123.                 }
  1124.             }
  1125.             else
  1126.             {
  1127.                 if (Request.Params["type"] == "sn")
  1128.                 {
  1129.                     SETTINGS_HEADER.InnerHtml = "Player Options - Stream Now";
  1130.                 }
  1131.                 else
  1132.                 {
  1133.                     SETTINGS_HEADER.InnerHtml = "Player Options - Manage Recordings";
  1134.                 }
  1135.             }
  1136.  
  1137.             transcodeOptions.Visible = false;
  1138.             MusicVideoControls.Visible = false;
  1139.  
  1140.             //Kill the VLC process on the server
  1141.             killVLC();
  1142.  
  1143.             //If we were streaming via the Stream Now option we need to get rid of the recording
  1144.             if (Request.Params["rid"] != null && Request.Params["type"] != null)
  1145.             {
  1146.                 if (Request.Params["type"] == "sn")
  1147.                 {
  1148.                     Schedule scheduleHelper = Global.Schedule;
  1149.                     ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  1150.                     if (scheduledRecording != null)
  1151.                     {
  1152.                         scheduleHelper.CancelScheduledRecording(scheduledRecording);
  1153.                         scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  1154.                         scheduleHelper.CancelScheduledRecording(scheduledRecording);
  1155.                     }
  1156.                 }
  1157.             }
  1158.         }
  1159.  
  1160.         protected static void killVLC()
  1161.         {
  1162.             // kill any existing VLC processes
  1163.             try
  1164.             {
  1165.                 foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcessesByName("vlc"))
  1166.                 {
  1167.                     thisproc.Kill();
  1168.                 }
  1169.             }
  1170.             catch (Exception Exc)
  1171.             {
  1172.             }
  1173.         }
  1174.     }
  1175. }